package RedMoon::Main;

use Exporter qw(import);
use strict;
use warnings;
use DBI;
use DBD::mysql;
our(@ISA,@EXPORT,@EXPORT_OK);
	
@EXPORT = qw();
@EXPORT_OK = qw();

use lib qw( /var/pwneth/htdocs/rpg/lib );
use RedMoon::Utils;

my $conf = '/var/pwneth/config';
my $utils = RedMoon::Utils->new;
	
sub new
{
    my $class = shift;
    my $self = {};
    bless $self, $class;
    my $caller = caller;
    $utils->writeLog("Core","INFO","Creating new object for $caller");
    return $self;
}

sub LoadModule
{
	shift if ref($_[0]);
	my($mod,$action) = @_;
	$action = "Main" unless ($action);
	my $tmpl = lc $mod;
	my($html) = $utils->readTemplate("Main/$tmpl", 1);
	my $dir = "/var/pwneth/htdocs/rpg/lib/RedMoon/Main/";
	my $req = $dir . $mod . ".pm";
	my $module = "RedMoon::Main::" . $mod;
		require $req;
		import $module;
	my $self = $module->new;
	my $content = $self->LoadContent($action);
	$utils->writeLog("LoadModule","INFO", "Loading content for $module");

		$html =~ s/\$CONTENT\$/$content/g;
		return ($html);
}

return 1;
